package Composite;

public class CompositeDemo {
    /*
    组合模式， 又叫部分整体模式。 用于把一组相似的对象当作一个 单一的对象。
    这种模式 创建了一个 包含自己对象组 的类。 该类提供了修改相同对象组的方式。
     */

    public static void main(String[] args) {
        Employee CEO = new Employee("Boss", "CEO", 30000);

        Employee headSales = new Employee("Jack", "Headers", 20000);
        Employee headMarketing = new Employee("Rose", "Headers", 20000);

        Employee clerk1 = new Employee("one", "sales", 10000);
        Employee clerk2 = new Employee("two", "sales", 10000);

        Employee worker1 = new Employee("three", "market", 10000);
        Employee worker2 = new Employee("four", "market", 10000);

        CEO.add(headSales);
        CEO.add(headMarketing);

        headSales.add(clerk1);
        headSales.add(clerk2);

        headMarketing.add(worker1);
        headMarketing.add(worker2);

        System.out.println(CEO);
        for (Employee e :
                CEO.getSubordinates()) {
            System.out.println("第一级子员工： " + e);

            for (Employee sube :
                    e.getSubordinates()) {
                System.out.println(" --- 第二级子员工" + sube);
            }
        }




    }
}
